import tkiTree from '@/components/tki-tree/tki-tree1.vue';
import safeData from '@/components/scene/distribute/safeList';
import loading from '@/components/xuan-loading/xuan-loading.vue';

import {
	log
} from 'util'

export default {

	data() {
		return {
			// 加载
			width: '150rpx',
			height: '100rpx',
			shadeShow: true,
			backgroundColor: "transparent",
			// 加载

			Inv: 5,
			datasList: {
				fCompanyid: "", // 左侧选中组织机构id
				page: 1, //页码
				pageSize: 20, //每页条数
				userId: "", // 查询待办或已办时传 列表页查询不传
				modelType: "", // 5-待办 6-已办
				fQualitygridclass: "", // 上方查询条件质量网格
				fQualitygridtype: "", // 上方查询条件工程网格
			},

			// 加载
			width: '150rpx',
			height: '100rpx',
			shadeShow: true,
			backgroundColor: "transparent",
			// 加载

			// 新增
			num: 0,
			userInfo: null,
			//列表数据
			unSubmitData: [],

			fCheckStatus: null, // 0 施工单位 1监理  2业主 3完成




		}
	},
	components: {
		safeData,
		loading,
		tkiTree,

	},
	onShow() {
		var that = this

		if (this.Inv == 5) {
			setTimeout(() => {
				that.unsubmit()
			}, 300)
		}
		if (this.Inv == 6) {
			setTimeout(() => {
				that.submit()

			}, 300)
		}

	},
	onLoad(option) {
		var that = this;
		uni.getStorage({ //监督检查方式
			key: 'userInfo',
			success: function(res) {
				that.userInfo = JSON.parse(res.data);
				that.getListData(that.Inv.toString());
			}
		});
	},
	// // 新增
	// onNavigationBarButtonTap(e) {
	// 	if (e.index === 0) {	
	// 		var url = "/pages/apply/behavior/onlineRecordWork/inter/index"	
	// 		uni.navigateTo({
	// 			url: url
	// 		});
	// 	}
	// },
	// 返回
	onBackPress(event) {
		uni.switchTab({
			url: '/pages/home/index'
		});
		return true;
	},

	methods: {
		// 跳详情页
		safeDetail(e) {

			if (e.Inv == 5) {
				uni.navigateTo({
					url: "/pages/apply/scene/distribute/inter/index?fid=" + e.id +
						"&" + "Inv=" + e.Inv
				});
				return false;
			} else if (e.Inv == 6) {
				uni.navigateTo({
					url: "/pages/apply/scene/distribute/submit/index?fid=" + e.id +
						"&" + "Inv=" + e.Inv
				});
				return false;
			}
		},
		// 跳详情页

		unsubmit() {
			var that = this
			this.Inv = 5;
			that.unSubmitData = [];
			this.getListData(this.Inv.toString())
		},
		submit() {
			var that = this
			this.Inv = 6;
			that.unSubmitData = [];
			this.getListData(this.Inv.toString())
		},


		callback() {},

		getListData(num) {
			var that = this;
			this.datasList = {
				fCompanyid: this.userInfo.companyId, // 左侧选中组织机构id
				page: 1, //页码
				pageSize: 20, //每页条数
				userId: this.userInfo.userId, // 查询待办或已办时传 列表页查询不传
				modelType: num, // 5-待办 6-已办
				fQualitygridclass: "", // 上方查询条件质量网格
				fQualitygridtype: "", // 上方查询条件工程网格
			}
			this.$refs.loadings.open();
			this.$http.getWorkOrderExecutionReport2PageLists(this.datasList).then(res => {
				if (res.errcode == 0) {
					that.unSubmitData = res.data.pageInfo.list;
					this.$refs.loadings.close();
				} else {
					uni.showToast({
						title: "获取数据失败",
						icon: 'none',
						duration: 2000
					});
					this.$refs.loadings.close();
				}
			}, (err) => {
				uni.showToast({
					title: "获取数据失败",
					icon: 'none',
					duration: 2000
				});
				this.$refs.loadings.close();
			});
		},

		callback() {

		},
	}
}
